package org.example.ObserverPattern;


public class ObserverTest {
    public static void main(String[] args) {
        Subject subject = new Subject();

        // 创建不同策略的观察者
        Observer observer1 = new ConcreteObserver("Staff", new ConsoleNotification());
        Observer observer2 = new ConcreteObserver("Student", new EmailNotification());
        Observer observer3 = new ConcreteObserver("Guest", new ConsoleNotification());
        Observer observer4 = new ConcreteObserver("Admin", new EmailNotification());

        // 测试添加多个观察者
        subject.addObserver(observer1);
        subject.addObserver(observer2);
        subject.addObserver(observer3);
        subject.addObserver(observer4);

        // 测试状态变更通知
        subject.setState("Accommodation 101 is now available!");



    }
}